﻿namespace DJLang
{
    public class DJString : DJRef<string>, IAdd, IEq
    {
        public DJString(string val) : base(val) { }

        public override IDJValue Clone() => new DJString(val);
        public override string ToString() => val;

        public IDJValue Add(IDJValue value) => value switch
        {
            DJBasic<int> i => new DJString(val + i.val),
            DJBasic<float> f => new DJString(val + f.val),
            DJBasic<bool> b => new DJString(val + b.val),
            DJRef<string> s => new DJString(val + s.val),
            _ => new DJErr($"Not supported string concat for {value}")
        };

        public IDJValue Eq(IDJValue value) => value switch
        {
            DJRef<string> s => new DJBasic<bool>(s.val == val),
            _ => new DJErr($"string eq not supported for {value}"),
        };
    }
}
